import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

export const constantRouterMap = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: () => import('@/views/redirect/index')
            }
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/auth-redirect',
        component: () => import('@/views/login/authredirect'),
        hidden: true
    },
    {
        path: '/404',
        component: () => import('@/views/errorPage/404'),
        hidden: true
    },
    {
        path: '/401',
        component: () => import('@/views/errorPage/401'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        name:'Index',
        meta:{title:'概况', icon:'appstore',key:'1', redirectKey:'1-1'},
        redirect: '/home',
        children: [
            {
                path: 'home',
                component: () => import('@/views/dashboard/index'),
                name: 'Home',
                hidden:true,
                meta: { title: '概况',key:'1-1', noCache: true }
            },

        ]
    },

]

export const asyncRouterMap = [
  {
    path: '/goods',
    component: Layout,
    name:'Goods',
    redirect: '/goodsList',
    meta:{title:'商品',key:'2', redirectKey:'2-1-1',icon:'inbox'},
    children: [
      {
        path: '/group_goods',
        component: () => import('@/views/goods/goods.vue'),
        meta: {title: '', key: '2-1', noCache: true},
        children: [
          {
            path: '/goodsList',
            component: () => import('@/views/goods/GoodsList.vue'),
            name: 'GoodsList',
            meta: {title: '商品列表', key: '2-1-1', noCache: true}
          },
          {
            path: '/goodsEdit/:id',
            component: () => import('@/views/goods/GoodsEdit.vue'),
            name: 'GoodsEdit',
            hidden:true,
            meta: {title: '编辑商品信息', key: '2-1-2', noCache: true}
          },
          {
            path: '/goodsTypeList',
            component: () => import('@/views/goods/GoodsTypeList.vue'),
            name: 'GoodsTypeList',
            meta: {title: '商品分类', key: '2-1-3', noCache: true}
          },
          {
            path: '/goodsUnitList',
            component: () => import('@/views/goods/GoodsUnitList.vue'),
            name: 'GoodsUnitList',
            meta: {title: '单位库', key: '2-1-4', noCache: true}
          }
        ]
      },
      {
        path: '/group_goods_order',
        component: () => import('@/views/goods/goods.vue'),
        meta: {title: ' ', key: '11-1', noCache: true},
        children: [
          {
            path: '/goods/saleList',
            component: () => import('@/views/goods/saleList.vue'),
            name: 'GoodsSaleList',
            meta: {title: '销售查询', key: '11-1-2', noCache: true}
          }
        ]
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    name: 'Order',
    redirect: '/orderList',
    meta: {title: '订单', key: '11', redirectKey: '11-1-1', icon: 'snippets'},
    children: [
      {
        path: '/group_order',
        component: () => import('@/views/order/order.vue'),
        meta: {title: ' ', key: '11-1', noCache: true},
        children: [
          {
            path: '/orderList',
            component: () => import('@/views/order/orderList.vue'),
            name: 'OrderList',
            meta: {title: '订单查询', key: '11-1-1', noCache: true}
          },
          {
            path: '/goods/saleList',
            component: () => import('@/views/goods/saleList.vue'),
            name: 'GoodsSaleList',
            meta: {title: '销售查询', key: '11-1-2', noCache: true}
          }
        ]
      },
      {
        path: '/group_dispatch',
        component: () => import('@/views/water/order/Order.vue'),
        meta: {title: ' ', key: '11-2', noCache: true},
        children: [
          {
            path: '/order/dispatchList',
            component: () => import('@/views/order/dispatchList.vue'),
            name: 'DispatchList',
            meta: {title: '网店发货', key: '11-2-1', noCache: true}
          }
        ]
      }
    ]
  },
  {
    path: '/member',
    component: Layout,
    name: 'Member',
    redirect: '/memberDashboard',
    meta: {title: '会员', key: '4', redirectKey:'4-1-1', icon: 'crown'},
    children: [
      {
        path: 'group_member_dashboard',
        component: () => import('@/views/member/member.vue'),
        meta: {title: '', key: '4-1', noCache: true},
        children: [
          {
            path: '/memberDashboard',
            component: () => import('@/views/member/MemberDashboard.vue'),
            name: 'MemberDashboard',
            meta: {title: '会员概况', key: '4-1-1', noCache: true}
          }
        ]
      },
      {
        path: 'group_member',
        component: () => import('@/views/member/member.vue'),
        meta: {title: '', key: '4-2', noCache: true},
        children: [
          {
            path: '/memberList',
            component: () => import('@/views/member/memberList'),
            name: 'MemberList',
            meta: {title: '用户查询', key: '4-2-1', noCache: true}
          },
          {
            path: '/vipList',
            component: () => import('@/views/member/vipList'),
            name: 'VipMemberList',
            meta: {title: '会员查询', key: '4-2-2', noCache: true}
          }
        ]
      }
    ]
  },
    {
        path: '/site',
        component: Layout,
        name: 'Site',
        redirect: '/siteList',
        meta: {title: '分站', key: '12', redirectKey: '12-1-1', icon: 'snippets'},
        children: [
            {
                path: '/group_site',
                component: () => import('@/views/site/site.vue'),
                meta: {title: ' ', key: '11-1', noCache: true},
                children: [
                    {
                        path: '/siteList',
                        component: () => import('@/views/site/siteList.vue'),
                        name: 'SiteList',
                        meta: {title: '分站管理', key: '12-1-1', noCache: true}
                    },
                    {
                        path: '/siteEdit',
                        component: () => import('@/views/site/siteEdit.vue'),
                        name: 'SiteEdit',
                        hidden:true,
                        meta: {title: '编辑分站信息', key: '12-1-2', noCache: true}
                    },
                    {
                        path: '/siteRegionList',
                        component: () => import('@/views/site/siteRegionList.vue'),
                        name: 'SiteRegionList',
                        hidden:true,
                        meta: {title: '区域管理', key: '12-1-3', noCache: true}
                    },
                    {
                        path: '/siteRegionEdit',
                        component: () => import('@/views/site/siteRegionEdit.vue'),
                        name: 'SiteRegionEdit',
                        hidden:true,
                        meta: {title: '编辑区域信息', key: '12-1-4', noCache: true}
                    },
                ]
            },
        ]
    },
  {
    path: '/user',
    component: Layout,
    name:'User',
    redirect: '/userList',
    meta:{title:'员工',key:'5', redirectKey:'5-1-1',icon:'team'},
    children: [
      {
        path: '/group_user',
        component: () => import('@/views/user/user.vue'),
        meta: { title:'',key:'5-1', noCache: true },
        children:[
          {
            path: '/userList',
            component: () => import('@/views/user/userList'),
            name: 'UserList',
            meta: { title: '员工管理',key:'5-1-1', noCache: true }
          },
          {
            path: '/userEdit',
            component: () => import('@/views/user/userEdit'),
            name: 'UserEdit',
            hidden:true,
            meta: { title: '编辑员工信息',key:'5-1-2', noCache: true }
          }
        ]
      },
      {
        path: '/group_rider',
        component: () => import('@/views/user/user.vue'),
        meta: { title:'',key:'5-2', noCache: true },
        children:[
          {
            path: '/riderList',
            component: () => import('@/views/user/riderList'),
            name: 'RiderList',
            meta: { title: '骑手管理',key:'5-2-3', noCache: true }
          },
          {
            path: '/riderEdit',
            component: () => import('@/views/user/riderEdit'),
            name: 'RiderEdit',
            hidden:true,
            meta: { title: '编辑骑手信息',key:'5-2-2', noCache: true }
          },
          {
            path: '/rider/orderList',
            component: () => import('@/views/user/orderList'),
            name: 'RiderOrderList',
            hidden:true,
            meta: { title: '骑手订单管理',key:'5-2-3', noCache: true }
          },
        ]
      }
    ]
  },
  {
    path: '/assets',
    component: Layout,
    name: 'Assets',
    redirect: '/assets/index',
    meta: {title: '资产', key: '6', redirectKey:'6-1-1', icon: 'pay-circle'},
    children: [
      {
        path: '/group_data_rider',
        component: () => import('@/views/assets/assets.vue'),
        meta: {title: ' ', key: '6-1', noCache: true},
        children: [
          {
            path: '/assets/index',
            component: () => import('@/views/assets/dashboard'),
            name: 'AssetsDashboard',
            meta: { title: '资产概况',key:'6-1-1', noCache: true }
          },
          {
            path: '/assets/billList',
            component: () => import('@/views/assets/billList'),
            name: 'BillList',
            meta: { title: '对账单',key:'6-1-2', noCache: true }
          },
          {
            path: '/assets/billDetail',
            component: () => import('@/views/assets/billDetail'),
            name: 'BillDetail',
            hidden:true,
            meta: { title: '对账单明细',key:'6-1-3', noCache: true }
          }
        ]
      },
      {
        path: '/group_data_water',
        component: () => import('@/views/water/water.vue'),
        meta: {title: '包装饮用水', key: '6-3', noCache: true},
        children: [
          {
            path: '/water/billList',
            component: () => import('@/views/water/billList'),
            name: 'WaterBillList',
            meta: { title: '对账单',key:'6-3-1', noCache: true }
          },
          {
            path: '/water/billDetail',
            component: () => import('@/views/water/billDetail'),
            name: 'WaterBillDetail',
            hidden:true,
            meta: { title: '对账单明细',key:'6-3-4', noCache: true }
          },
          // {
          //   path: '/water/saleList',
          //   component: () => import('@/views/water/saleList'),
          //   name: 'WaterSaleList',
          //   meta: { title: '销售查询',key:'6-3-2', noCache: true }
          // },
          {
            path: '/water/depositList',
            component: () => import('@/views/water/depositList.vue'),
            name: 'WaterDepositList',
            meta: {title: '桶押金', key: '6-3-3', noCache: true}
          }
        ]
      },
      {
        path: '/group_data_daily',
        component: () => import('@/views/daily/daily.vue'),
        meta: {title: '日用百货', key: '6-4', noCache: true},
        children: [
          {
            path: '/daily/billList',
            component: () => import('@/views/daily/billList'),
            name: 'DailyBillList',
            meta: { title: '对账单',key:'6-4-1', noCache: true }
          },
          {
            path: '/daily/billDetail',
            component: () => import('@/views/daily/billDetail'),
            name: 'DailyBillDetail',
            hidden:true,
            meta: { title: '对账单明细',key:'6-4-2', noCache: true }
          }
        ]
      },
      {
        path: '/group_data_rider',
        component: () => import('@/views/user/user.vue'),
        meta: {title: '骑手', key: '6-2', noCache: true},
        children: [
          {
            path: '/rider/deductList',
            component: () => import('@/views/user/deductList'),
            name: 'RiderDeduct',
            meta: { title: '佣金查询',key:'6-2-1', noCache: true }
          }
        ]
      }
    ]
  },
  {
    path: '/marketing',
    component: Layout,
    name: 'Marketing',
    redirect: '/activityList',
    meta: {title: '营销', key: '7', redirectKey: '7-1-1', icon: 'shopping-cart'},
    children: [
      {
        path: '/group_marketing',
        component: () => import('@/views/marketing/marketing.vue'),
        meta: {title: '', key: '7-1', noCache: true},
        children: [
          {
            path: '/activityList',
            component: () => import('@/views/marketing/activityList'),
            name: 'ActivityList',
            meta: {title: '优惠活动', key: '7-1-1', noCache: true}
          },
          {
            path: '/activityEdit',
            component: () => import('@/views/marketing/activityEdit'),
            name: 'ActivityEdit',
            hidden:true,
            meta: {title: '编辑活动', key: '7-1-2', noCache: true}
          },
          {
            path: '/activity/goodsList',
            component: () => import('@/views/marketing/goodsList'),
            name: 'ActivityGoods',
            hidden:true,
            meta: {title: '活动商品管理', key: '7-1-2', noCache: true}
          },
          {
            path: '/adList',
            component: () => import('@/views/marketing/adList'),
            name: 'AdList',
            meta: {title: '广告位', key: '7-1-6', noCache: true}
          },
          {
            path: '/adEdit',
            component: () => import('@/views/marketing/adEdit'),
            name: 'AdEdit',
            hidden:true,
            meta: {title: '编辑广告', key: '7-1-7', noCache: true}
          },
          {
            path: '/couponList',
            component: () => import('@/views/coupon/couponList.vue'),
            name: 'CouponList',
            meta: {title: '优惠券', key: '7-1-3', tabs:[{title:'进行中',key:'USING',path:'/couponList?active=USING'},{title:'未开始',key:'NOT_START',path:'/couponList?active=NOT_START'},{title:'已结束',key:'ENDED',path:'/couponList?active=ENDED'}], noCache: true}
          },
          {
            path: '/couponDetail',
            component: () => import('@/views/coupon/couponEdit.vue'),
            name: 'CouponDetail',
            hidden: true,
            meta: {title: '优惠券详情', key: '7-1-4', noCache: true}
          },
          {
            path: '/couponAdd',
            component: () => import('@/views/coupon/couponAdd.vue'),
            name: 'CouponAdd',
            hidden: true,
            meta: {title: '新增优惠券', key: '7-1-5', noCache: true}
          }
        ]
      }
    ]
  },
  {
    path: '/notice',
    component: Layout,
    name: 'Notice',
    redirect: '/noticeList',
    meta: {title: '消息', key: '8', redirectKey: '8-1-1', icon: 'bell'},
    children: [
      {
        path: '/group_notice',
        component: () => import('@/views/system/system.vue'),
        meta: {title: ' ', key: '8-1', noCache: true},
        children: [
          {
            path: '/noticeList',
            component: () => import('@/views/system/noticeList'),
            name: 'NoticeList',
            meta: {title: '公告管理', key: '8-1-1', noCache: true}
          }
        ]
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    name: 'System',
    redirect: '/setInfo',
    meta: {title: '设置', key: '10', redirectKey:'10-1-1', icon: 'setting'},
    children: [
      {
        path: '/group_system',
        component: () => import('@/views/system/system.vue'),
        meta: {title: '通用', key: '10-1', noCache: true},
        children: [
          {
            path: '/setInfo',
            component: () => import('@/views/system/setInfo'),
            name: 'SetInfo',
            meta: {title: '配置参数', key: '10-1-1', noCache: true}
          },
          {
            path: '/pubData',
            component: () => import('@/views/system/pubData'),
            name: 'PubData',
            meta: {title: '公共参数', key: '10-1-4', noCache: true}
          }
        ]
      },
      {
        path: '/group_template',
        component: () => import('@/views/template/template.vue'),
        meta: {title: '网店模板', key: '10-3', noCache: true},
        children: [
          // {
          //   path: '/templateSelect',
          //   component: () => import('@/views/template/templateSelect'),
          //   name: 'TemplateSelect',
          //   hidden: true,
          //   meta: {title: '选择模板', key: '10-3-1', noCache: true}
          // },
          {
            path: '/templateBuild',
            component: () => import('@/views/template/templateBuild'),
            name: 'TemplateBuild',
            meta: {title: '编辑模板', key: '10-3-2', active:'template', tabs:[{title:'店铺搭建',key:'template',path:'/templateBuild'},{title:'店铺配置',key:'detail',path:'/companyDetail?active=detail'}], noCache: true}
          },
          {
            path: '/companyDetail',
            component: () => import('@/views/template/companyDetail'),
            name: 'CompanyDetail',
            meta: {title: '店铺信息', key: '10-3-3', active:'detail', tabs:[{title:'店铺搭建',key:'template',path:'/templateBuild'},{title:'店铺配置',key:'detail',path:'/companyDetail'}], noCache: true}
          }
        ]
      },

    ]
  },
]
export const componentsMap = {

}

export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
})